//
//  Map.m
//  PacIsBack
//
//  Created by Simon André on 31/01/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "Map.h"
#import "AreaType.h"


@implementation Map

@synthesize squares, musicType;


-(id) initWithDefaultValues{
	if (self = [super init]) {
		NSMutableArray* onlyLine = [[NSMutableArray alloc] init];
		AreaType* onlySquare = [[AreaType alloc] initWithDefaultValues];
		[onlyLine addObject:onlySquare];
		[onlySquare release];
		NSMutableArray* defaultSquares = [[NSMutableArray alloc] init];
		[defaultSquares addObject:onlyLine];
		[onlyLine release];
		[self setSquares:defaultSquares];
		[defaultSquares release];
	}
	return self;
}

-(id<AreaTypeProtocol>) areaTypeAtCoordinateX:(NSUInteger) coordinateX andY:(NSUInteger) coordinateY{
	if (coordinateY <= [[self squares] count]) {
		NSArray* Yline = [[self squares] objectAtIndex:coordinateY-1];
		if (coordinateX <= [Yline count]) {
			return [Yline objectAtIndex:coordinateX-1];
		}
	}
	return nil;
}

- (void) dealloc{
	[self setSquares:nil];
	[self setMusicType:nil];
	[super dealloc];
}

@end
